package cn.edu.nchu;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class RuleMachineApplication {
    @Value("${emqx.username}")
    private String username;

    @Value("${emqx.password}")
    private String password;

    public static void main(String[] args) {
        SpringApplication.run(RuleMachineApplication.class);
    }

    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplateBuilder()
                // basic验证
                .basicAuthentication(username, password)
                .build();
    }
}
